<?
require_once ROOT_PATH.'boot/req_inc.php';
/**
 * 数据库适配器
 * 
 * 数据库连接适配器类，提供各种数据库的基本属性构造（主机，用户名，密码等)，目前只实现了mysql数据库相关操作
 * 
 * @package Utils-Interface
 * @access public
 * @abstract 抽象类
 * @author 张东宇
 * @version 1.0
 */
abstract class Utils_Interface_Adapter {
	protected $host; //定义连接数据库主机
	protected $port;//端口号
	protected $username; //定义连接数据库用户名
	protected $password = ""; //定义连接数据库密码
	protected $database; //定义连接数据库名
	protected $charset = 'UTF-8'; //字符集
	protected $section = null; //配置文件中配置片段

	function binding($section) {
		$this->section=$section;
		if(is_array($section))
		{
	   		$this->host = $this->section ['host'];
			$this->port = $this->section ['port'];
			$this->username = $this->section ['username'];
			$this->password = $this->section ['password'];
			$this->database = $this->section ['database'];
			$this->charset = $this->section ['charset'];
		}else 
		{
			$context=$GLOBALS['context'];
			$this->host = $context->get_app_conf('db_host');
			$this->port = $context->get_app_conf('db_port');
			$this->username = $context->get_app_conf('db_user');
			$this->password = $context->get_app_conf('db_pass');
			$this->database = $context->get_app_conf('db_name');
			$this->charset = $context->get_app_conf('db_charset');
		}
			
//			echo  $context->get_app_conf('db_charset');
	}
}